namespace Ajax_Learning.Migrations
{
    using Ajax_Learning.Models;
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;

    internal sealed class Configuration : DbMigrationsConfiguration<Ajax_Learning.Models.RestaurentsContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

        protected override void Seed(Ajax_Learning.Models.RestaurentsContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //
            for (int i = 0; i < 1000; i++)
            {
                context.Restaurents.AddOrUpdate(
                    p => p.Name, new Restaurent
                    {
                        Name = i.ToString(),
                        Location = "Ha noi",
                        Country = "Viet Nam"
                    }
                    );
            }
        }
    }
}
